home *** CD-ROM | disk | FTP | other *** search
/ Shocking The Web CD-ROM / SHOCK_CD.ISO / pc / tutorial / ch07_au / cmddemos / bitmanul.dir / 00003_Bandwidth Determinator Script.ls < prev    next >
Encoding:
Text File  |  1996-10-23  |  1.0 KB  |  32 lines

  1. global gBitTestData, gBitTestFlag, gKPerSec
  2.  
  3. on startBitCheck
  4.   set bSize to 10000 + random(100)
  5.   getNetText("http://www.dxm.com/cgi/spew.cgi?" & string(bSize))
  6.   set bandID to getLatestNetID()
  7.   set gBitTestData to [#ID: bandID, #start: the ticks, #size: integer(bSize), #finish: 0]
  8.   set gBitTestFlag to 1
  9.   debug("Checking Your Bandwidth.  This will take a few seconds.")
  10. end
  11.  
  12. on checkBitstream
  13.   if netDone(getaProp(gBitTestData, #ID)) then
  14.     if netError() = "OK" then
  15.       setaProp(gBitTestData, #finish, the ticks)
  16.       set testTime to getaProp(gBitTestData, #finish) - getaProp(gBitTestData, #start)
  17.       set gKPerSec to float(getaProp(gBitTestData, #size) / 1000) / float(testTime / 60)
  18.       debug(string(gKPerSec))
  19.       set foo to netTextResult(getaProp(gBitTestData, #ID))
  20.       set foo to 0
  21.       if gKPerSec > 10 then
  22.         set bandwidth to 1
  23.       else
  24.         set bandwidth to 0
  25.       end if
  26.       makePref("bandwidth", bandwidth)
  27.       radio(string(bandwidth) & "-band")
  28.     end if
  29.     set gBitTestFlag to 0
  30.   end if
  31. end
  32.